package com.liyu.listener;

import com.liyu.config.PriorityExchangeCommon;
import com.rabbitmq.client.Channel;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

import java.io.IOException;
import java.nio.charset.StandardCharsets;

/**
 * @author 李誉
 * @date 2022-08-07 13:34
 * @description
 */
@Slf4j
@Component
public class ProrityCusumer {

    @RabbitListener(queues = PriorityExchangeCommon.PRIORITY_QUEUE)
    public void priorityListener(Channel channel, Message message) throws IOException {
        log.info("消费消息：{}", new String(message.getBody(), StandardCharsets.UTF_8));
        channel.basicAck(message.getMessageProperties().getDeliveryTag(), false);
    }
}
